package com.wealth.scsj.b_app.view.activity;

import android.graphics.Color;
import android.os.Build;
import android.support.v4.view.ViewPager;
import android.os.Bundle;

import com.wealth.scsj.b_app.R;
import com.wealth.scsj.b_app.adapter.FragmentAdapter;
import com.wealth.scsj.b_app.view.fragment.basemodel.BaseFragment;
import com.wealth.scsj.b_app.view.fragment.fourmodel.MineFragment;
import com.wealth.scsj.b_app.view.fragment.fourmodel.OrderFragment;
import com.wealth.scsj.b_app.view.fragment.fourmodel.ShopFragment;
import com.wealth.scsj.b_app.view.fragment.fourmodel.WaitFragment;

import java.util.ArrayList;

import devlight.io.library.ntb.NavigationTabBar;


public class MainActivity extends BaseActivity {

    private ViewPager viewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        intiNavigationBar();
    }

    @Override
    protected void createView(Bundle savedInstanceState) {

    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {

    }

    private void intiNavigationBar() {
        viewPager = findViewById(R.id.vp);
        viewPager.setOffscreenPageLimit(4);

        ArrayList<BaseFragment> fragmentList = new ArrayList<>();

        WaitFragment waitFragment = new WaitFragment();
        OrderFragment orderFragment = new OrderFragment();
        ShopFragment shopFragment = new ShopFragment();
        MineFragment mineFragment = new MineFragment();

        fragmentList.add(orderFragment);
        fragmentList.add(waitFragment);
        fragmentList.add(shopFragment);
        fragmentList.add(mineFragment);

        FragmentAdapter mAdpter = new FragmentAdapter(getSupportFragmentManager(), fragmentList);
        viewPager.setAdapter(mAdpter);

        final NavigationTabBar navigationTabBar = findViewById(R.id.ntb);
        final ArrayList<NavigationTabBar.Model> models = new ArrayList<>();

        models.add(
                new NavigationTabBar.Model.Builder(
                        getResources().getDrawable(R.mipmap.home_unselected),
                        Color.parseColor("#00000000"))
                        .title("待处理")
                        .selectedIcon(getResources().getDrawable(R.mipmap.home_selected))
                        .build()
        );
        models.add(
                new NavigationTabBar.Model.Builder(
                        getResources().getDrawable(R.mipmap.home_unselected),
                        Color.parseColor("#00000000"))
                        .title("订单管理")
                        .selectedIcon(getResources().getDrawable(R.mipmap.home_selected))
                        .build()

        );
        models.add(
                new NavigationTabBar.Model.Builder(
                        getResources().getDrawable(R.mipmap.home_unselected),
                        Color.parseColor("#00000000"))
                        .title("门店运营")
                        .selectedIcon(getResources().getDrawable(R.mipmap.home_selected))
                        .build()
        );

        models.add(
                new NavigationTabBar.Model.Builder(
                        getResources().getDrawable(R.mipmap.home_unselected),
                        Color.parseColor("#00000000"))
                        .title("我的")
                        .selectedIcon(getResources().getDrawable(R.mipmap.home_selected))
                        .build()
        );

        navigationTabBar.setModels(models);
        navigationTabBar.setViewPager(viewPager, 0);
        navigationTabBar.setBehaviorEnabled(false);
        navigationTabBar.setTitleMode(NavigationTabBar.TitleMode.ALL);
        navigationTabBar.setIsTitled(true);
        navigationTabBar.setIsTinted(false);
        navigationTabBar.setIsSwiped(false);
        navigationTabBar.setBgColor(Color.WHITE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            navigationTabBar.setNestedScrollingEnabled(false);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            navigationTabBar.setNestedScrollingEnabled(false);
        }
    }
}
